<?php


namespace App\Http\Server;
use App\Models\Restock;

class RestockServer
{

    public function addRestockServer($id,$goods_id,$num,$now_date,$manufacturer_id,$cost_price,$total_price){
        if(isset($id) && !empty($id)){
            $model = Restock::find($id);
        }else{
            $model = new Restock();
        }
        $model->goods_id = $goods_id;
        $model->num = $num;
        $model->now_date = $now_date;
        $model->manufacturer_id = $manufacturer_id;
        $model->cost_price = $cost_price;
        $model->total_price = $total_price;
        $model->save();
        return ['status'=>200,'data'=>$model,'msg'=>'success'];
    }

    /**
     * 获取客户列表
     * @param $customer_name
     * @param $customer_phone
     */
    public function getRestockListServer($params,$per_page=10)
    {
        // 执行查询
        $users = Restock::Search($params)->with(['goods','manufacturer'])->paginate($per_page)->toArray();
        return ['status'=>200,'data'=>$users['data'],'msg'=>'success'];
    }
}
